package com.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;

import mqtt.Application;

@RestController
public class DriverlessDataController {

	@SuppressWarnings("unchecked")
	@RequestMapping(value ="GetDataInfor",method = RequestMethod.GET)	
	public DriverlessDataItem GetDataInfor()
	{
		DriverlessDataItem driverlessDataItem = new DriverlessDataItem();

		Map<String,Object> map =new HashMap<String,Object>();
		//为空
		if(Application.conentData.isEmpty())
		{
			return driverlessDataItem;
		}
		 map = JSONObject.parseObject(Application.conentData, Map.class);
		 map = (Map<String,Object>)map.get("items");
		 
		 Map<String,Object> rollerReadyOkDic= (Map<String,Object>)map.get("RollerReadyOk");
		 Map<String,Object> workSpeedActDic= (Map<String,Object>)map.get("WorkSpeedAct");
		 Map<String,Object> engineSpeedActDic= (Map<String,Object>)map.get("EngineSpeedAct");
		 Map<String,Object> steerAngleActDic= (Map<String,Object>)map.get("SteerAngleAct");
		 Map<String,Object> vibrateStatusDic= (Map<String,Object>)map.get("VibrateStatus");
		 Map<String,Object> workStatusDic= (Map<String,Object>)map.get("WorkStatus");
		 Map<String,Object> LongitudeDic= (Map<String,Object>)map.get("longitude");
		 Map<String,Object> LatitudeDic= (Map<String,Object>)map.get("Latitude");
		 
		 
		 //System.out.print(rollerReadyOkDic.get("value"));
		 driverlessDataItem.RollerReadyOk = (int)rollerReadyOkDic.get("value");
		 driverlessDataItem.WorkSpeedAct = (int)workSpeedActDic.get("value");
		 driverlessDataItem.EngineSpeedAct = (int)engineSpeedActDic.get("value");
		 driverlessDataItem.SteerAngleAct = (int)steerAngleActDic.get("value");
		 driverlessDataItem.VibrateStatus = (int)vibrateStatusDic.get("value");
		 driverlessDataItem.WorkStatus = (int)workStatusDic.get("value");
		 driverlessDataItem.Longitude = (int)LongitudeDic.get("value");
		 driverlessDataItem.Latitude = (int)LatitudeDic.get("value");
		 
		 return driverlessDataItem;
		 
		 
	}
}
